/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package boxoffice;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;

/**
 * PurchaseWindow - The window that appears when you actually buy your
 * tickets!
 * @author Alex
 */
public class PurchaseWindow extends JFrame implements ActionListener {
    private JTextArea text;
    private JButton accept;
    private JButton decline;
    
    /**
     * PurchaseWindow() - Constructors! This puts our very simple window
     * together.
     */
    public PurchaseWindow() {
        text = new JTextArea();
        accept = new JButton("Accept");
        decline = new JButton("Decline");
        
        Container content = getContentPane();
        
        content.add(text, BorderLayout.NORTH);
        
        JPanel buttons = new JPanel(new GridLayout(2,0));
        
        buttons.add(accept, BorderLayout.CENTER);
        buttons.add(decline, BorderLayout.CENTER);
        
        content.add(buttons, BorderLayout.SOUTH);
        
        text.setText("Thank you for purchasing your tickets. You will be"
                + " charged $90 for two seats. Have a nice day.");
    }
    
    /**
     * actionPerformed() - Watches for any wanted or important actions that
     * may be done by the user.
     * @param e The ActionEvent that was caught by our function.
     */
    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == accept) {
            this.setVisible(false);
        }
        
        if (e.getSource() == decline) {
            this.setVisible(false);
        }
    }
}
